package com.lagou.filter;

import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;

/**
 * 性能监控拓展过滤器
 * @author 陶肖寅
 * @version V1.0
 * @Package org.apache.dubbo.rpc.Filter
 * @email fromlx@126.com
 * @date 2020-04-17 00:46
 * @Copyright © 2020-2021 城云科技(中国)有限公司
 */
@Activate(group={CommonConstants.CONSUMER})
public class TPMonitorFilter implements Filter {
    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        long startTime=0;
        try {
            startTime = System.currentTimeMillis();
            return invoker.invoke(invocation);
        } finally {
            System.out.println("invoke time:"+(System.currentTimeMillis()-startTime));
        }

    }
}
